﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RegisterationCommon.Common;
using RegisterationCommon.School;

namespace RegisterationSystem.Space_School
{
    public partial class account_modifypswd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //获取用户名
                username.InnerHtml = Cookies.Get("SchoolAccountName");
            }
        }

        protected void btnadd_Click(object sender, EventArgs e)
        {
            //判断原密码是否正确
            if (BaseLibrary.ConvertToMD5(OldAccountPswd.Value.ToLower()) != Cookies.Get("SchoolAccountPswd"))
            {
                Message.Send(10027);
                return;
            }
            //Account.Current.ID =Convert.ToInt64( Cookies.Get("AccountID"));
            //获取用户修改密码(MD5加密)
            if (Cookies.Get("SchoolAccountPswd").ToString() == BaseLibrary.ConvertToMD5(NewAccountPswd.Value.ToLower()))
            {
                //新密码于原密码相同
                //修改成功
                Message.Send(10028);
                return;
            }
            SchoolAccount.Current.AccountPswd = BaseLibrary.ConvertToMD5(NewAccountPswd.Value.ToLower());
            if (SchoolAccount.Current.MdfSchoolAccountPwd())
            {
                //修改成功
                Message.Send(10029);
            }
            else
            {
                //修改失败
                Message.Send(10030);
                return;
            }
        }
    }
}